<?php
class Admin_Model_Choix extends Zend_Db_Table_Abstract
{
	public function updateVentes($data, $id)
	{
	    $sql = "UPDATE ventes SET ";
	    $sql .= "dtvente='". $data['dtvente'] ."'";
	    $sql .= ",titre='". $data['titre'] ."'";
	    $sql .= ",com='". $data['com'] ."'";
	    $sql .= ",visible='". $data['visible'] ."'";
	    $sql .= ",rep_photos='". $data['rep'] ."'";
	    $sql .= ",premier='". $data['premier'] ."'";
	    $sql .= ",second='". $data['second'] ."'";
	    $sql .= ",troisieme='". $data['troisieme'] ."'";
	    $sql .= ",cat_premier='". $data['cat_premier'] ."'";
	    $sql .= ",cat_second='". $data['cat_second'] ."'";
	    $sql .= ",cat_troisieme='". $data['cat_troisieme'] ."'";
	    $sql .= ",catalogue='". $data['catalogue'] ."'";
	    $sql .= ",cat_dispo='". $data['cat_dispo'] ."'";
	    $sql .= ",dtlimiteordre='". $data['dtlimiteordre'] ."'";
	    $sql .= ",auteur='". $data['auteur'] ."'";
	    $sql .= ",photographe='". $data['photographe'] ."'";
	    $sql .= ",msg_dispo_cat='". $data['msg_dispo_cat'] ."'";
	    $sql .= ",resultats='". $data['resultats'] ."'";
	    $sql .= ",articles_en_ligne='". $data['articles_en_ligne'] ."'";
	    $sql .= ",type_vente='". $data['type_vente'] ."'";
	    $sql .= ",expo='". $data['expo'] ."'";
	    $sql .= ",renum='". $data['renum'] ."'";
	    $sql .= ",expo='". $data['expo'] ."'";
        $sql .= " where p_ventes = $id";
        
        return $this->getAdapter()->query($sql);
	}
	
	public function getListUser()
	{
		$sql = "SELECT p_admin,nom,prenom FROM admin WHERE userid <> 'creabel' ORDER BY nom,prenom";
		return $this->getAdapter()->fetchAll($sql);
	}
	
	public function insertVentesUser($data)
	{
	    $sql  = "INSERT INTO admin(nom,prenom,userid,password,email,limited,superadmin) VALUES (";
	    $sql .= "'". $data['nom'] ."'";
	    $sql .= ",'". $data['prenom'] ."'";
	    $sql .= ",'". $data['userid'] ."'";
	    $sql .= ",'". $data['password'] ."'";
	    $sql .= ",'". $data['email'] ."'";
	    $sql .= ",'". $data['limited'] ."'";
	    $sql .= ",0";
	    $sql .= ")";
	    
	    return $this->getAdapter()->query($sql);
	}
	
	public function getRenumByVente($num_vente)
	{
	    $sql = "SELECT renum FROM ventes WHERE p_ventes = " . $num_vente;
		return $this->getAdapter()->fetchRow($sql);
	}
	
}